package model.playable.unit;
import model.command.*;
import model.playable.*;
import java.util.*;
import model.visibility.*;
import model.mapping.*;
import model.map.GameTile;

public class Worker extends Unit implements Prospectable, Researchable
{
	boolean available;

	public Worker(PlayableUser player, List<String> walkableTerrains)
	{
		setWalkableTerrains(walkableTerrains);
		setPlayer(player);
		setIdNumber(-1);
		setUpkeep(1);
		setInfluenceRadius(0);
		setVisibilityRadius(1);
		setCommandQueue(new LinkedList<Command>());
		setCommandsPossibleList(createCommandPossibleList());
		setCurrentPossibleCommandPosition(0);
		setIsInStandBy(false);
		setIsPoweredDown(false);
		setArmyId(-1);
		setRallyPointId(-1);
		setVehicleId(-1);
		setMovementSpeed(1);
		setIsBattleGroup(false);
		setIsReinforcement(false);
		setAvailable(true);
	}
	
	public LinkedList<Command> createCommandPossibleList()
	{
		LinkedList<Command> possibleCommands = new LinkedList<Command>();
		possibleCommands.add(new PowerDown(this));
		possibleCommands.add(new PowerUp(this));
		possibleCommands.add(new Decommission(this));
		possibleCommands.add(new Standby(this));
		possibleCommands.add(new Prospect(this));
		possibleCommands.add(new Move(this));
		return possibleCommands;
	} 
	
	public boolean getAvailable()
	{
		return available;
	}
	
	public void setAvailable(boolean available)
	{
		this.available = available;
	}
	
	public void prospect()
	{
		System.out.println("This unit executed prospect" );
	}
	
	public void research(String technology)
	{
		System.out.println("This unit executed research" );
	}
	
	public void createMelee()
	{
		System.out.println("This unit executed create melee" );
	}
	
	public void createRanged()
	{
		System.out.println("This unit executed create ranged" );
	}
	
	public void createExplorer()
	{
		System.out.println("This unit executed create explorer" );
	}
	
	public void createWorker()
	{
		System.out.println("This unit executed create worker" );
	}
	
	public void createVehicle()
	{
		System.out.println("This unit executed create vehicle" );
	}
	
	public void accept(PlayableVisitor pv)
	{
		pv.visitWorker(this);
	}
	
	public GameTile getLocation()
	{
		return PlayableMapping.getPlayableMapping().getLocationOfWorker(this);
	}
	
	public String toString()
	{
		return "Worker";
	}
}